package com.hospital.hospital.service.impl;

import com.hospital.hospital.bean.Drug;
import com.hospital.hospital.mapper.DrugMapper;
import com.hospital.hospital.service.DrugService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * @author xfm
 * @create 2021/9/4
 */
@Service
public class DrugServiceImpl implements DrugService {
    @Autowired
    public DrugMapper drugMapper;
    @Override
    public List<Drug> show() throws Exception {
        List<Drug> drugs = drugMapper.queryAll();
        return drugs;
    }

    @Override
    public void add(String dname,Double sprice,Integer num) throws Exception {
        drugMapper.insert(dname,sprice,num);
    }

    @Override
    public Drug queryByDname(String dname) throws Exception {
        Drug drug = drugMapper.queryByDname(dname);
        return drug;
    }

    @Override
    public void reduce(Integer id, Integer num) throws Exception {
        drugMapper.reduce(id,num);
    }

    @Override
    public void update(Integer id,Integer num,Double sprice) throws Exception {
        drugMapper.update(id,num,sprice);
    }

    @Override
    public void delete(Integer id) throws Exception {
        drugMapper.delete(id);
    }

    @Override
    public Drug queryById(Integer id) throws Exception {
        Drug drug = drugMapper.queryById(id);
        return drug;
    }
}
